<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const patients = [
  {
    id: '001',
    name: 'Alice',
    age: 34,
    gender: 'F',
    bloodPressure: {
      systolic: 120,
      diastolic: 80
    },
    hasDiabetes: false
  },
  {
    id: '002',
    name: 'Charlie',
    age: 47,
    gender: 'M',
    bloodPressure: {
      systolic: 140,
      diastolic: 90
    },
    hasDiabetes: true
  },
  {
    id: '003',
    name: 'Bob',
    age: 55,
    gender: 'M',
    bloodPressure: {
      systolic: 130,
      diastolic: 95
    },
    hasDiabetes: false
  }
];
// console.log(patients[1].name.substring(0,1));

// const arr ={
//   id: string,
//   name: string,
//   age: number,
//   gender: string,
//   bloodPressure: {
//     systolic: number,
//     diastolic: number
//   },
//   hasDiabetes: boolean
// }
const getHighBloodPressurePatients = function(data,a,b){
    const Output = data.filter(item=>{
        return item.bloodPressure.systolic>a||item.bloodPressure.diastolic<b
    })
    // console.log(Output[0].name.substring(0,1));
    for(let i = 0;i<Output.length-1;i++){
    for(let i = 0;i<Output.length-1;i++){
        if(Output[i].name.substring(0,1)>Output[i+1].name.substring(0,1)){
            [Output[i],Output[i+1]]=[Output[i+1],Output[i]]
        }
    }
}

    // console.log(Output);
    return Output
}
const highBloodPressurePatients = getHighBloodPressurePatients(patients, 125, 85);

console.log(highBloodPressurePatients);
// Output:
// [
//   {
//     id: '001',
//     name: 'Alice',
//     age: 34,
//     gender: 'F',
//     bloodPressure: { systolic: 120, diastolic: 80 },
//     hasDiabetes: false
//   },
//   {
//     id: '003',
//     name: 'Charlie',
//     age: 55,
//     gender: 'M',
//     bloodPressure: { systolic: 130, diastolic: 95 },
//     hasDiabetes: false
//   }
// ]
    </script>
</body>
</html>